﻿@model dynamic

@{
	ViewBag.Title = "重庆医保接口请求窗口";
	Layout = "~/Views/Shared/_Index.cshtml";

}
<style>
	#btn_clean {
		background-color: #fff;
		color: #00a9ea;
		font-weight: bolder;
	}
</style>
<form name="form1" autocomplete="off">
	<div class="panel panel-default">
		<div class="panel-heading navb-bg">
			Request
		</div>
		<div style="padding-right:20px;">
			<table class="form">
				<tr>
					<th class="formTitle"><span class="required">*</span>Intferface：</th>
					<td class="formValue">
						<input type="text" class="form-control" id="txt_it" value="http://127.0.0.1:33333/api/YiBao/" />
					</td>
					<td class="formValue">
						<button type="button" class="btn btn-primary" id="btn_request" value="请求" style="width: 100px;">Send</button>
						<button type="button" class="btn btn-primary" id="btn_clean" value="清除" style="width: 100px;">Clean</button>
					</td>
				</tr>
				<tr>
					<th class="formTitle"><span class="required">*</span>BodyXml：</th>
					<td class="formValue" colspan="2">
						<textarea type="text" class="form-control" id="txt_body" rows="9" cols="20"></textarea>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<div class="panel panel-default" style="margin-bottom: 0">
		<div class="panel-heading navb-bg">
			Response
		</div>
		<div style="padding: 2px;padding-right:20px;">
			<table class="form">
				<tr>
					<th class="formTitle">ResponseXml：</th>
					<td class="formValue">
						<textarea type="text" class="form-control" id="txt_response" rows="14" cols="20"></textarea>
					</td>
				</tr>
			</table>
		</div>
	</div>
</form>

<script lang="javascript">
	$(function () {
		$("#btn_request").click(function () {
			$("#txt_response").val("");
			//var payoptype = { "inStr":  };//险种类别默认，1、医疗保险；2、工伤保险；3、生育保险；
			$.ajax({
				type: "POST",
                url: $("#txt_it").val(),
                dataType: "json",
                data: JSON.parse($("#txt_body").val()),
				async: false,
				success: function (data) {
					$("#txt_response").val(data);
				}
			});
		});
		$("#btn_clean").click(function () {
			$("#txt_it").val("");
			$("#txt_body").val("");
			$("#txt_response").val("");
		});
	});

	//回车事件绑定
	$(document).keyup(function (event) {
		if (event.keyCode === 13) {
			$("#btn_request").trigger("click");
		}
	});
</script>